package com.scuec.groupfive.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.scuec.groupfive.entity.QuestionInfo;
import com.scuec.groupfive.mapper.QuestionMappper_two;
import com.scuec.groupfive.service.QuestionService_two;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QuestionServiceImpl_two implements QuestionService_two {

    @Autowired
    private QuestionMappper_two questionMapper;

    /**
     * 获取所有题目列表（不分页）
     * @return 题目列表
     */
    @Override
    public List<QuestionInfo> getQuestionList() {
        return questionMapper.getQuestionList();
    }

    /**
     * 分页获取题目列表
     * @param pageNum 当前页码
     * @param pageSize 每页显示数量
     * @return 分页题目信息
     */
    @Override
    public PageInfo<QuestionInfo> getQuestionPages(Integer pageNum, Integer pageSize) {
        // 启动分页
        PageHelper.startPage(pageNum, pageSize);
        // 获取分页数据（PageHelper会自动分页）
        List<QuestionInfo> questionList = questionMapper.getQuestionList();
        // 用PageInfo封装结果
        return new PageInfo<>(questionList);
    }
}
